iT邦幫忙

0

請教大神在同一TABLE進行金額欄位乘除後COUNT 並區分能達成一行顯示嗎

sql
  • 分享至 

  • xImage
  •  

小弟在統計臨櫃匯出匯款筆數、金額時卡住了.....

想詢問版上的大大,下圖為最終顯示結果
小弟該如何下指令會比較好..../images/emoticon/emoticon02.gif
https://ithelp.ithome.com.tw/upload/images/20240410/20137200ygJ1u7vkh7.png

下方是小弟目前算出匯出的幣別並折成美金

SELECT A.REMIT_CCY,COUNT(0) ,
CASE WHEN REMIT_CCY ='AUD' THEN SUM(ROUND(REMIT_AMT * B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='CAD' THEN SUM(ROUND(REMIT_AMT / B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='CHF' THEN SUM(ROUND(REMIT_AMT / B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='CNY' THEN SUM(ROUND(REMIT_AMT / B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='EUR' THEN SUM(ROUND(REMIT_AMT * B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='GBP' THEN SUM(ROUND(REMIT_AMT * B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='HKD' THEN SUM(ROUND(REMIT_AMT / B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='JPY' THEN SUM(ROUND(REMIT_AMT / B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='NZD' THEN SUM(ROUND(REMIT_AMT * B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='SGD' THEN SUM(ROUND(REMIT_AMT / B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='ZAR' THEN SUM(ROUND(REMIT_AMT / B.EXRATE_EVALUATE,2))
WHEN REMIT_CCY ='USD' THEN SUM(ROUND(REMIT_AMT * B.EXRATE_EVALUATE,2)) END AS 折美金額
FROM FRORTM A
LEFT JOIN CMXRVM_CBUS B ON A.REMIT_CCY=B.CCY AND B.VALID_DATE ='20240200'
WHERE TXNT_DATE>='20240201' and TXNT_DATE<='20240231' GROUP BY REMIT_CCY ORDER BY REMIT_CCY

https://ithelp.ithome.com.tw/upload/images/20240410/20137200U4AduBwjxR.png

下圖是區分法金 / 個金 判別方式

select CLIENT_CODE,sum(CNT) from ( select case when SUBSTRING(REMITTER_ID,9,1)=' ' then '法金' else '個金' end as CLIENT_CODE, count(*) as CNT from FRORTM where TXNT_DATE>='20240201' and TXNT_DATE<='20240231' group by SUBSTRING(REMITTER_ID,9,1) ) as d group by CLIENT_CODE ORDER BY 1

https://ithelp.ithome.com.tw/upload/images/20240410/20137200RJpkqR80cu.png


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言